"""
多个网页循环爬取
"""
from pprint import pprint

import requests, re
from bs4 import BeautifulSoup

for i in range(0, 250, 25):
    if i == 0:
        url = "https://movie.douban.com/top250"
    else:
        url = f"https://movie.douban.com/top250?start={i}&filter="
    response = requests.get(url, headers={"User-Agent": "Moozilla/5.0 (Windows NT 10.0; Win64; x64)"})
    print(response.status_code)
    response.encoding = "utf-8"
    if response.ok:
        movies = re.findall('<span class="title">([\u4e00-\u9fa5]+)</span>', response.text)
        print(movies)
        print(f"-----------------------第{i / 25 + 1}页结束--------------------------------")
    else:
        print("获取数据失败")
